package platform.common.web;

import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;

public class MyOpenSessionInViewFilter extends OpenSessionInViewFilter {
	
	public MyOpenSessionInViewFilter() {
		super.setFlushMode(FlushMode.AUTO);
	}

	protected void closeSession(Session session, SessionFactory sessionFactory) {
		session.flush();

		try {
			session.getTransaction().commit();
		} catch (HibernateException e) {
			// TODO Auto-generated catch block//e.printStackTrace();
			
		}
        //System.out.println("关闭连接");
		super.closeSession(session, sessionFactory);
	}

}
